package com.mydemo.ssl;

import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import java.net.URL;

/**
 * 获取交互的TLS版本
 */
public class SSLInfo {
    public static void main(String[] args) throws Exception {
        URL url = new URL("https://appdownload.kjtpay.com/");
        HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
        SSLContext sslContext = SSLContext.getInstance("TLSv1.1");
        sslContext.init(/*keyManagers*/null, /*trustManagers*/null, /*new SecureRandom()*/null); // simple here
        conn.setSSLSocketFactory(new SecureSSLSocketFactory(sslContext.getSocketFactory(),new MyHandshakeCompletedListener()));
        conn.connect();
    }
}
